/*
* Copyright 2016 Yonyou Auto Information Technology（Shanghai） Co., Ltd. All Rights Reserved.
*
* This software is published under the terms of the YONYOU Software
* License version 1.0, a copy of which has been included with this
* distribution in the LICENSE.txt file.
*
* @Project Name : marketing-wechat-open-api
*
* @File name : LoveModelController.java
*
* @Author : LiuJun
*
* @Date : 2016年12月29日
*
----------------------------------------------------------------------------------
*     Date       Who       Version     Comments
* 1. 2016年12月29日    LiuJun    1.0
*
*
*
*
----------------------------------------------------------------------------------
*/
	
package com.yonyou.gmcc.gateway.wechat.controller.customerinfo;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.marketing.common.constants.BusinessConstant;
import org.marketing.common.dto.customerInfo.LoveModelDto;
import org.marketing.common.util.CheckUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.yonyou.gmcc.gateway.wechat.common.ApiVersionConsts;
import com.yonyou.gmcc.gateway.wechat.controller.BaseController;
import com.yonyou.gmcc.gateway.wechat.service.interfaces.CustomerInfoApiServiceInterface;

/**
*
* @author LiuJun
* 心仪车型controller
* @date 2016年12月29日
*/
@RestController
@RequestMapping(value = ApiVersionConsts.BASE_PATH+"/loveModel")
public class LoveModelController extends BaseController{
    
    @Autowired
    private CustomerInfoApiServiceInterface customerInfoApiServiceInterface;
    
    /**
    *
    * @author LiuJun
    * 获取心仪车型
    * @date 2016年12月29日
    * @param request
    * @param response
    * @return
    * @throws Exception
    */
    @RequestMapping(method = RequestMethod.GET,produces = "application/json;charset=UTF-8")
    public List<LoveModelDto> getLoveModelData(HttpServletRequest request, HttpServletResponse response) throws Exception{
        String dealerCode = getDealerCode(request);
        if(CheckUtil.NullOrEmpty(dealerCode)){
            dealerCode = BusinessConstant.EMPTY_STRING;
        }
        Long potentialUserId = getPotentialUserId(request);
        List<LoveModelDto> dtoList = customerInfoApiServiceInterface.getLoveModelData(dealerCode, potentialUserId);
        if(CheckUtil.NullOrEmpty(dtoList)){
            return new ArrayList<>();
        }
        return dtoList;
    }


}
